package com.easyshopping;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.easyshopping.facade.ShoppingListFacade;

public class AddCategoryActivity extends Activity implements OnClickListener {

	private Button btn_Cancel;
//	private Button btn_addCategoryOK;
	private Button btn_addCategory;
	private EditText et_Category;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		this.setContentView(R.layout.add_category);
		
		btn_Cancel = (Button) this.findViewById(R.id.Btn_Add_Cancel);
		btn_Cancel.setOnClickListener(this);
		
//		btn_addCategoryOK = (Button) this.findViewById(R.id.Add_Category_OK);
//		btn_addCategoryOK.setOnClickListener(this);
		
		btn_addCategory = (Button) this.findViewById(R.id.Btn_Add_Category);
		btn_addCategory.setOnClickListener(this);
		
		et_Category = (EditText) this.findViewById(R.id.Add_Category_EditText);
		
	}
	
	public void onClick(View view) {
		
		if(view.equals(btn_Cancel)){
			this.finish();
			return;
		}
		
		if(view.equals(btn_addCategory)){
			if(et_Category.getText().length() != 0){
				String cateText = et_Category.getText().toString();
				ShoppingListFacade.getInstance().addItemCategory(cateText);
				et_Category.setText("");
				et_Category.setHint(R.string.continue2add);
			}
		}
	}
}
